package com.api.oa.mapper;


import com.api.oa.model.entity.OaOfficeNav;
import com.api.oa.model.entity.OaOrgClassify;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
@Mapper
public interface OaOfficeNavMapper {


    @Insert("insert into oa_office_nav (" +
            "officeTitle," +
            "officeIcon," +
            "officeInfo," +
            "officeType," +
            "officeAt" +
            ") " +
            "values " +
            "(" +
            "#{business.officeTitle}," +
            "#{business.officeIcon}," +
            "#{business.officeInfo}," +
            "#{business.officeType}," +
            "#{business.officeAt}" +
            ")" )

    @Options(useGeneratedKeys = true,keyProperty = "officeId",keyColumn = "id")
    int insert(@Param("business") OaOfficeNav business);


    @Update("update oa_office_nav set officeTitle = #{org.officeTitle}, officeIcon=#{org.officeIcon}, officeInfo=#{org.officeInfo}, officeType=#{org.officeType} where officeId = #{org.officeId}")
    int update(@Param("org") OaOfficeNav org);


    @Delete("delete from oa_office_nav where officeId = #{id}")
    void delete(@Param("id") Long id);


    @Select("<script>  select * from oa_office_nav <if test='keyWord!=null || keyWord!=\"\"'> where officeTitle like concat('%',#{keyWord},'%') </if> </script>")
    Page<OaOfficeNav> list(@Param("keyWord") String keyWord);


    @Select("select * from oa_office_nav where officeId = #{id} limit 1")
    OaOfficeNav findOne(@Param("id") Long id);

}
